package com.dm.webCrawler.framework.file;

import java.io.InputStream;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class FileSystemUtil {

	@Value("${lb.file-system.type}")
	private String saveType;
	
	@Autowired
	private FileSystemInterface fileSystemInterface;
	
	public String httpPrefix() {
		return fileSystemInterface.httpPrefix();
	}
	
	/**
	 * 保存文件到文件系统，不会关闭流
	 * @param savePath 保存路径
	 * @param localFileInput 本地文件流
	 * @return
	 */
	public boolean saveFile(String savePath,InputStream localFileInput) {
		return fileSystemInterface.saveFile(savePath, localFileInput);
	}

	/**
	 * 检测服务中是否存在文件。。。
	 * @param savePath
	 * @return
	 */
	public boolean hasFile(String filePath) {
		return fileSystemInterface.hasFile(filePath);
	}

	/**
	 * 删除文件
	 * @param ccdz
	 * @return
	 */
	public boolean deleteFile(String filePath) {
		// TODO Auto-generated method stub
		return fileSystemInterface.deleteFile(filePath);
	}
	
}
